home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbdatabs / strdb.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-03-17  |  5.9 KB  |  158 lines

  1. // ------------------------------- //
  2. // -------- Start of File -------- //
  3. // ------------------------------- //
  4. // ----------------------------------------------------------- //
  5. // C++ Header File Name: strdb.h 
  6. // Compiler Used: MSVC40, DJGPP 2.7.2.1, GCC 2.7.2.1, HP CPP 10.24
  7. // Produced By: Doug Gaer   
  8. // File Creation Date: 09/17/1997  
  9. // Date Last Modified: 03/18/1999
  10. // Copyright (c) 1997 Douglas M. Gaer
  11. // ----------------------------------------------------------- // 
  12. // ---------- Include File Description and Details  ---------- // 
  13. // ----------------------------------------------------------- // 
  14. /*
  15. The VBD C++ classes are copyright (c) 1997, by Douglas M. Gaer.
  16. All those who put this code or its derivatives in a commercial
  17. product MUST mention this copyright in their documentation for
  18. users of the products in which this code or its derivative
  19. classes are used. Otherwise, you have the freedom to redistribute
  20. verbatim copies of this source code, adapt it to your specific
  21. needs, or improve the code and release your improvements to the
  22. public provided that the modified files carry prominent notices
  23. stating that you changed the files and the date of any change.
  24.  
  25. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
  26. THE ENTIRE RISK OF THE QUALITY AND PERFORMANCE OF THIS SOFTWARE
  27. IS WITH YOU. SHOULD ANY ELEMENT OF THIS SOFTWARE PROVE DEFECTIVE,
  28. YOU WILL ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
  29. CORRECTION.
  30.  
  31. The StrDB class is a general purpose string database used to
  32. represent one unique key member, 7 general purpose members,
  33. and one comment block. All the string members can grow and
  34. shrink as needed
  35. */
  36. // ----------------------------------------------------------- //   
  37. #ifndef __STRDB_HPP__
  38. #define __STRDB_HPP__
  39.  
  40. #include "persist.h"
  41. #include "dbvers.h"
  42.  
  43. const INT32 StrDBVersion = 1024; // String database class version number
  44.  
  45. typedef UString KeyMember; // Key alphanumeric data member 
  46. typedef UString Member2;   // Second alphanumeric data member  
  47. typedef UString Member3;   // Third alphanumeric data member 
  48. typedef UString Member4;   // Fourth alphanumeric data member 
  49. typedef UString Member5;   // Fifth alphanumeric data member 
  50. typedef UString Member6;   // Sixth alphanumeric data member 
  51. typedef UString Member7;   // Seventh alphanumeric data member 
  52. typedef UString Member8;   // Eighth alphanumeric data member 
  53. typedef UString Comment;   // Comment alphanumeric data member 
  54.  
  55. // String Database class
  56. class StrDB : public Persistent
  57. {
  58. public:
  59.   StrDB() { KM = M2 = M3 = M4 = M5 = M6 = M7 = M8 = CM = "\0"; }
  60.   StrDB(const POD *pod) : Persistent(pod) {
  61.     KM = M2 = M3 = M4 = M5 = M6 = M7 = M8 = CM = "\0"; 
  62.   }
  63.   StrDB(POD *pod) : Persistent(pod) {
  64.     KM = M2 = M3 = M4 = M5 = M6 = M7 = M8 = CM = "\0"; 
  65.   }
  66.   StrDB(const StrDB &ob) { Copy(ob); }
  67.   void operator=(const StrDB &ob) { Copy(ob); }
  68.   
  69. public: 
  70.   void SetKM(const char *s) { KM = s; }
  71.   void SetKM(const UString &s) { KM = s; }
  72.   void SetM2(const char *s) { M2 = s; }
  73.   void SetM2(const UString &s) { M2 = s; }
  74.   void SetM3(const char *s) { M3 = s; }
  75.   void SetM3(const UString &s) { M3 = s; }
  76.   void SetM4(const char *s) { M4 = s; }
  77.   void SetM4(const UString &s) { M4 = s; }
  78.   void SetM5(const char *s) { M5 = s; }
  79.   void SetM5(const UString &s) { M5 = s; }
  80.   void SetM6(const char *s) { M6 = s; }
  81.   void SetM6(const UString &s) { M6 = s; }
  82.   void SetM7(const char *s) { M7 = s; }
  83.   void SetM7(const UString &s) { M7 = s; }
  84.   void SetM8(const char *s) { M8 = s; }
  85.   void SetM8(const UString &s) { M8 = s; }
  86.   void SetCM(const char *s) { CM = s; }
  87.   void SetCM(const UString &s) { CM = s; }
  88.   const char *GetKM() const { return KM.c_str(); }
  89.   char *GetKM() { return KM.c_str(); }
  90.   const char *GetM2() const { return M2.c_str(); }
  91.   char *GetM2() { return M2.c_str(); }
  92.   const char *GetM3() const { return M3.c_str(); }
  93.   char *GetM3() { return M3.c_str(); }
  94.   const char *GetM4() const { return M4.c_str(); }
  95.   char *GetM4() { return M4.c_str(); }
  96.   const char *GetM5() const { return M5.c_str(); }
  97.   char *GetM5() { return M5.c_str(); }
  98.   const char *GetM6() const { return M6.c_str(); }
  99.   char *GetM6() { return M6.c_str(); }
  100.   const char *GetM7() const { return M7.c_str(); }
  101.   char *GetM7() { return M7.c_str(); }
  102.   const char *GetM8() const { return M8.c_str(); }
  103.   char *GetM8() { return M8.c_str(); }
  104.   const char *GetCM() const { return CM.c_str(); }
  105.   char *GetCM() { return CM.c_str(); }
  106.   INT32 Version() { return StrDBVersion; }
  107.  
  108. public:
  109.   void Copy(const StrDB &ob);
  110.   int FullCompare(const StrDB &ob);
  111.  
  112. private: // Base class interface
  113.   virtual FAU Write();
  114.   virtual void Read(FAU Address);
  115.   virtual FAU Find();
  116.   virtual FAU Delete();
  117.   virtual FAU Remove();
  118.  
  119. public: // Base class interface
  120.  
  121.   // 02/05/1998 Changed to public access
  122.   virtual INT32 GetClassID() const { return SClassID; }
  123.  
  124.   // 02/05/1998 Changed to public access
  125.   virtual const char *GetClassName() { return "Class StrDB"; }
  126.  
  127.   virtual unsigned ObjectLength();
  128.   virtual void SetObjectAddress(FAU addr) { objectaddress = addr; }
  129.   virtual FAU GetObjectAddress() { return objectaddress; }
  130.   virtual int CompareIndex();
  131.   virtual int RebuildIndexFile(const char *fname);
  132.  
  133. public: // Overloaded operators
  134.   friend int operator==(const StrDB &a, const StrDB &b);
  135.   friend int operator!=(const StrDB &a, const StrDB &b);
  136.   friend int operator>(const StrDB &a, const StrDB &b);
  137.   friend int operator>=(const StrDB &a, const StrDB &b);
  138.   friend int operator<(const StrDB &a, const StrDB &b);
  139.   friend int operator<=(const StrDB &a, const StrDB &b);
  140.   
  141. private:
  142.   KeyMember KM;
  143.   Member2 M2;
  144.   Member3 M3;
  145.   Member4 M4;
  146.   Member5 M5;
  147.   Member6 M6;
  148.   Member7 M7;
  149.   Member8 M8;
  150.   Comment CM;
  151. };
  152.  
  153. #endif  // __STRDB_HPP__ 
  154. // ----------------------------------------------------------- // 
  155. // ------------------------------- //
  156. // --------- End of File --------- //
  157. // ------------------------------- //
  158.